package org.springblade.modules.admin.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springblade.core.tool.utils.Func;
import org.springframework.util.AutoPopulatingList;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 电梯停梯状态
 * @Author ysq
 * @Date 2021/10/23
 **/
@Getter
@AllArgsConstructor
public enum ElevatorFaultLevelEnum {

	ONE(1,"一级事件"),
	TWO(2,"二级事件"),
	THREE(3,"三级事件"),
	FOUR(4,"四级事件"),
	FIVE(5,"五级事件"),
	SIX(6,"六级事件");

	final int status;

	final String name;

	public static String getName(int status){
		ElevatorFaultLevelEnum[] values = ElevatorFaultLevelEnum.values();
		for (ElevatorFaultLevelEnum enumValue:values) {
			if(enumValue.getStatus()==status){
				return enumValue.getName();
			}
		}
		return null;
	}

	/**
	 * 根据 level 传参，获取<=level的所有status，并返回对应的SStringValue
	 * @param level int
	 * @return String 拼接好的描述字符串
	 */
	public static String getStatusDescListByLevel(int level){
		ElevatorFaultLevelEnum[] values = ElevatorFaultLevelEnum.values();
		List<String> statusDescList = new ArrayList<>();
		for (ElevatorFaultLevelEnum enumValue:values) {
			if(enumValue.getStatus()<=level){
				statusDescList.add(String.valueOf(enumValue.getStatus()));
			}
		}
		if(Func.isEmpty(statusDescList)){
			return "";
		}
		return String.join(",",statusDescList);
	}
}
